<%@ page contentType="text/html; charset=utf-8"%>
<%@ include file="/global/jsp-header.jsp"%>
<c:set var="operator" value="${operatorType eq 1}"></c:set>
<!DOCTYPE HTML>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html">
		<title>访问数据范围</title>
		<%@ include file="/global/tablesort-header.jsp"%>
		<script>
		$(document).ready(function(){
			window.parent.updateTitle("${actionUri.actionName}");
			$(':radio').attr('disabled', true);
			$(':checkbox:checked').each(function(){
				$(this).parent().siblings().find(':radio').removeAttr('disabled');
			});

			$(':checkbox[name=rangeIds]').click(function(){
				if($(this).attr('checked')) {
					$(this).parent().siblings().find(':radio').removeAttr('disabled');
				} else {
					$(this).parent().siblings().find(':radio').attr('disabled', true);
				}
			});
			
			<c:if test="${operator}">
				setTimeout("window.parent.closeOperatorDialog();", 3000);
			</c:if>
			
		});
		</script>
	</head>
	<body>
		<c:choose>
		<c:when test="${operator }">
			${ operatorMsg}
		</c:when>
		<c:otherwise>
			<c:if test="${allActionRange.size() > 0}">
				<table id="myTable" cellspacing="1" class="tablesorter">
					<thead>
						<tr>
							<th>
								范围ID
							</th>
							<th>
								范围名称
							</th>
							<th>
								单/多选
							</th>
						</tr>
					</thead>
					<tbody>
						<form action="/rbac/edit-action-with-range.do" name="myform" id="myform"  method="post">
							<input type="hidden" name="actionUri.actionId" value="${actionUri.actionId }">
							<c:forEach items="${allActionRange }" var="item">
								<tr rangeId=${item.rangeId }>
									<c:set value="${false}" var="aorChecked"></c:set>
						 			<c:set value="${0}" var="isRadio"></c:set>
						 			<c:forEach items="${dataList}" var="aor">
						 				<c:if test="${!aorChecked && item.rangeId eq aor.rangeId}">
						 					<c:set value="${true}" var="aorChecked"></c:set>
						 					<c:set value="${aor.isRadio}" var="isRadio"></c:set>
						 				</c:if>
						 			</c:forEach>
									<td>
	 									<label for="a_${item.rangeId }">${item.rangeId }</label>
										<input type="checkbox" name="rangeIds" value="${item.rangeId }" ${aorChecked ? 'checked="checked"' : '' }/>
									</td>
									<td>
										${item.rangeName }
									</td>
									<td>
										<label for="ir_${item.rangeId }_1">单选</label>
										<input type="radio" name="isRadio_${item.rangeId }" value="1" id="ir_${item.rangeId }_1"  ${isRadio eq 1 ? 'checked="checked"' : '' }/>
	 									<label for="ir_${item.rangeId }_2">多选</label>
	 									<input type="radio" name="isRadio_${item.rangeId }" value="0" id="ir_${item.rangeId }_2" ${isRadio eq 0 ? 'checked="checked"' : '' }/>
									</td>
								</tr>
							</c:forEach>
							<input type="submit"  class="button blue" value="提交" />
						</form>
					</tbody>
				</table>
			</c:if>
			<c:if test="${allActionRange.size() <= 0}">
				<div class="emptyResult">
					抱歉，没有找到相关数据范围。
				</div>
			</c:if>
		</c:otherwise>
		</c:choose>
	</body>
</html>
